/* 
** (Copyright) sejishikong <sejishikong@263.net>
** Authors:    sejishikong <sejishikong@263.net>
**             Wei Lian <lianwei2003.student@sina.com> 
** Maintainer: Wei Lian
**    This program is free software; you can redistribute it and/or modify
**    it under the terms of the GNU General Public License Version 2 as
**    published by the Free Software Foundation;
**
**    This program is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**    GNU General Public License for more details.
**
**    You should have received a copy of the GNU General Public License
**    along with this program; if not, write to the Free Software
**    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
*/

#include "header.h"
#include "mainwindow.h"
#include "sys.h"
#include "config.h"
#include "fork.h"
#include "loadsave.h"
#include "channel.h"
#include "menubar.h"
#include "mystatusbar.h"
#include "record.h"

Sopcast::Sopcast (QWidget * parent, const char *name):
QVBox (parent, name)
{
  //menubar
  menubar = new MenuBar (this);

  ///row
  QHBox *hbox = new QHBox (this);
  buttonchannel = new QToolButton (hbox);
  buttonchannel->setTextLabel ("Channel");
  buttonchannel->setAutoRaise (true);
  buttonchannel->setUsesTextLabel (true);
  buttonchannel->setToggleButton (TRUE);

  editsearch = new QLineEdit ("", hbox);
  editsearch->setFocus ();

  buttonsearch = new QToolButton (hbox);
  buttonsearch->setTextLabel ("Search");
  buttonsearch->setAutoRaise (true);
  buttonsearch->setUsesTextLabel (true);

  buttonexpand = new QToolButton (hbox);
  buttonexpand->setTextLabel ("Expand");
  buttonexpand->setAutoRaise (true);
  buttonexpand->setUsesTextLabel (true);


  /////vboxconfig
  vboxconfig = new Config (this);
  menubar->vboxconfig = vboxconfig;
  ///fork
  fork = new Fork (this);
  menubar->fork = fork;
  fork->config = vboxconfig;
  ///record
  record = new Record (this);
  record->fork = fork;
  record->vboxconfig = vboxconfig;

  ///row
  channel = new Channel (this);
  menubar->channel = channel;
  vboxconfig->channel = channel;
  channel->vboxconfig = vboxconfig;

  ////row
  hbox = new QHBox (this);
  buttonplayer = new QToolButton (hbox);
  buttonplayer->setTextLabel ("Player");
  buttonplayer->setAutoRaise (true);
  buttonplayer->setUsesTextLabel (true);
  buttonplayer->setToggleButton (TRUE);
  QToolButton *buttonstop = new QToolButton (hbox);
  buttonstop->setTextLabel ("Stop");
  buttonstop->setAutoRaise (true);
  buttonstop->setUsesTextLabel (true);

  sys = new Sys (this);
  slidersound =
    new QSlider (0, 100, 10, sys->sound_read (), QSlider::Horizontal, hbox);

  buttonrecord = new QToolButton (hbox);
  buttonrecord->setTextLabel ("Record");
  buttonrecord->setAutoRaise (true);
  buttonrecord->setUsesTextLabel (true);


  ///row
  statusbar = new MyStatusBar (this);
  message[0] = new QLabel (this);
  statusbar->addWidget (message[0], 1, 0);
  for (int i = 1; i < 6; i++)
    {
      message[i] = new QLabel (this);
      message[i]->hide();
    }


/////signal and slot  
  connect (slidersound, SIGNAL (valueChanged (int)), sys,
	   SLOT (sound_write (int)));
  connect (buttonchannel, SIGNAL (clicked ()), channel,
	   SLOT (fetchchannel ()));
  connect (buttonstop, SIGNAL (clicked ()), this,
	   SLOT (onbuttonstopclicked ()));
  connect (buttonplayer, SIGNAL (toggled (bool)), this,
	   SLOT (onButtonPlayerToggled (bool)));
  connect (buttonrecord, SIGNAL (clicked ()), record,
	   SLOT (onbuttonrecordclicked ()));
  connect (buttonexpand, SIGNAL (clicked ()), this,
	   SLOT (onbuttonexpandclicked ()));
  connect (buttonsearch, SIGNAL (clicked ()), this,
	   SLOT (onbuttonsearchclicked ()));
  connect (editsearch, SIGNAL (returnPressed ()), this,
	   SLOT (onbuttonsearchclicked ()));




  QTimer *timer = new QTimer (this);
  connect (timer, SIGNAL (timeout ()), this, SLOT (timerDone ()));
  timer->start (1000, FALSE);

////initialization
  loadsave = new LoadSave (this);
}

Sopcast::~Sopcast ()
{
  delete loadsave;
}
